//
//  DCHViewControllerZHUYAO.m
//  DCH-BaiSiBuDeJie
//
//  Created by apple on 16/10/18.
//  Copyright © 2016年 xiaomage. All rights reserved.
//

#import "DCHViewControllerZHUYAO.h"
#import "DCHViewControllerJINGHUA.h"
#import "DCHViewControllerGUANZHU.h"
#import "DCHTableViewControllerWO.h"
#import "DCHViewControllerXINTIE.h"
#import "DCHViewControllerFABU.h"
#import "UIImage+RenDar.h"
#import "UITabBarItem+Font.h"
#import "DCHUINavigationController.h"

@interface DCHViewControllerZHUYAO ()

@property (nonatomic,strong) UIButton * plusButton;

@end

@implementation DCHViewControllerZHUYAO

- (UIButton *)plusButton
{
    if (_plusButton ==nil) {
        
        //创建一个按钮
        UIButton *btn =[UIButton buttonWithType:UIButtonTypeCustom];
        _plusButton =btn;
        [btn setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"tabBar_publish_click_icon"] forState:UIControlStateHighlighted];
        //自适应
        [btn sizeToFit];
        
        [self.tabBar addSubview:btn];
        
    }

    return _plusButton;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    
  self.plusButton.center =CGPointMake(self.tabBar.bounds.size.width * 0.5, self.tabBar.bounds.size.height * 0.5);
   
    
    //字体的颜色
    self.tabBar.tintColor  =[UIColor blackColor];
    
    [self DaoHang];
    [self TuPian];
  
}

//设置所有导航控制器的按钮
- (void)TuPian
{

//精华
    UINavigationController *nav =self.childViewControllers[0];
    nav.tabBarItem.title =@"精华";
    nav.tabBarItem.image =[UIImage imageNamed:@"tabBar_essence_icon"];
    //自定义方法 让图片不被渲染
    nav.tabBarItem.selectedImage = [UIImage imageNameWithOringinal:@"tabBar_essence_click_icon"];
    //字体的大小
    [nav.tabBarItem setupTaBarButtonFont:[UIFont systemFontOfSize:12]];
//新帖
    UINavigationController *nav1 =self.childViewControllers[1];
    nav1.tabBarItem.title =@"新帖";
    nav1.tabBarItem.image =[UIImage imageNamed:@"tabBar_new_icon"];
    nav1.tabBarItem.selectedImage =[UIImage imageNameWithOringinal:@"tabBar_new_click_icon"];
    
    [nav1.tabBarItem setupTaBarButtonFont:[UIFont systemFontOfSize:12]];
//发布
    UIViewController *nav2 =self.childViewControllers[2];
    nav2.tabBarItem.enabled =NO;
   
    
    [nav2.tabBarItem setupTaBarButtonFont:[UIFont systemFontOfSize:12]];
//关注
    UINavigationController *nav3 =self.childViewControllers[3];
    nav3.tabBarItem.title =@"关注";
    nav3.tabBarItem.image =[UIImage imageNamed:@"tabBar_friendTrends_icon"];
    nav3.tabBarItem.selectedImage = [UIImage imageNameWithOringinal:@"tabBar_friendTrends_click_icon"];
    [nav3.tabBarItem setupTaBarButtonFont:[UIFont systemFontOfSize:12]];
//我
    UINavigationController *nav4 =self.childViewControllers[4];
    nav4.tabBarItem.title =@"我";
    nav4.tabBarItem.image =[UIImage imageNamed:@"tabBar_me_icon"];
    nav4.tabBarItem.selectedImage = [UIImage imageNameWithOringinal:@"tabBar_friendTrends_click_icon"];
    
    [nav4.tabBarItem setupTaBarButtonFont:[UIFont systemFontOfSize:12]];
    
 

}

//添加导航控制器
- (void)DaoHang
{
//精华
    DCHViewControllerJINGHUA *jinHua  =[[DCHViewControllerJINGHUA alloc]init];
    jinHua.view.backgroundColor =[UIColor redColor];
    
    UINavigationController *nav =[[UINavigationController alloc]initWithRootViewController:jinHua];
    [self addChildViewController:nav];
    
    
    //新帖
    DCHViewControllerXINTIE *xinTie =[[DCHViewControllerXINTIE alloc]init];
    xinTie.view.backgroundColor =[UIColor yellowColor];
    
    UINavigationController *nav3 =[[UINavigationController alloc]initWithRootViewController:xinTie];
    [self addChildViewController:nav3];
   
//发布
    DCHViewControllerFABU *faBu =[[DCHViewControllerFABU alloc]init];
    faBu.view.backgroundColor =[UIColor greenColor];
    
    UINavigationController *nav4 =[[UINavigationController alloc]initWithRootViewController:faBu];
    
    [self addChildViewController:nav4];
    
    //关注
    
    DCHViewControllerGUANZHU *guanZhu =[[DCHViewControllerGUANZHU alloc]init];
    guanZhu.view.backgroundColor =[UIColor orangeColor];
    
    UINavigationController *nav1 =[[UINavigationController alloc]initWithRootViewController:guanZhu];
    [self addChildViewController:nav1];
    
    //我
    DCHTableViewControllerWO *Wo =[[DCHTableViewControllerWO alloc]init];
    DCHUINavigationController *ller =[[DCHUINavigationController alloc]initWithRootViewController:Wo];
    
    [self addChildViewController:ller];
    
   
}

@end
